﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;

using DreamCube.WebServer.WinServiceModel;

namespace DreamCube.WebServer.WinService
{
    [RunInstaller(true)]
    public partial class ProjectInstaller : System.Configuration.Install.Installer
    {
        public ProjectInstaller()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 执行安装
        /// </summary>
        public void DoSetup()
        {
            IDictionary result = new Hashtable();
            this.Commit(result);
        }

        /// <summary>
        /// 安装完毕之后触发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ProjectInstaller_AfterInstall(Object sender, InstallEventArgs e)
        {
            //using (System.ServiceProcess.ServiceController sc = new System.ServiceProcess.ServiceController(Common.ServiceName))
            //{
            //    sc.Start();
            //}
            using (System.ServiceProcess.ServiceController sc = new System.ServiceProcess.ServiceController(Common.KeepLiveServiceName))
            {
                sc.Start();
            }
        }
    }
}
